<template>
  <!-- 统计页面 -->
  <div class="stats-box">
    <el-button-group>
      <el-button
        type="primary"
        :class="currentBtnState == 0 ? 'isActive' : ''"
        @click="clickCount"
        >统计</el-button>
      <el-button
        type="primary"
        :class="currentBtnState == 1 ? 'isActive' : ''"
        @click="clickSeting"
        >设置</el-button>
    </el-button-group>

    <!-- 统计页面 -->
    <template v-if="currentBtnState==0">
      <count ref="countRef" @countEmit="countEmit"></count>
    </template>

    <!-- 设置页面 -->
    <template v-else-if="currentBtnState==1">
      <seting ref="setingRef"></seting>
    </template>
  </div>
</template>

<script>
import count from './count.vue'
import seting from './seting.vue'
export default {
  name: 'stats',
  components:{
    count,
    seting
  },
  data(){
    return{
      currentBtnState: 0,//0统计 1设置
    }
  },
  methods:{
    // 初始化调用
    openCountRef(){
      this.$nextTick(()=>{
        this.$refs.countRef.goInit() //初始化调用
      })
    },

    // 点击了统计
    clickCount(){
      this.currentBtnState = 0
      this.$nextTick(()=>{
        this.$refs.countRef.goInit() //初始化调用
      })
    },

    // 点击了设置
    clickSeting(){
      this.currentBtnState = 1
      this.$nextTick(()=>{
        this.$refs.setingRef.getCircleMembersFn() //初始化调用
      })
    },

    // 点击了统计查询按钮
    countEmit(u,e){
      this.$emit('statsEmit',u,e)
    },
  },
}
</script>

<style lang="scss" scoped>
@import "./index.scss";
</style>